package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

//@Aspect
@Component
public class RecordTime {
    @Around("execution(public * com.itheima.controller.EmpController.*(..))")
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        Long startTime = System.currentTimeMillis();
        Object result = pjp.proceed();
        Long endTime = System.currentTimeMillis();
        Long totalTime = endTime - startTime;
        String methodName = pjp.getSignature().getName();
        System.out.println(methodName+"耗时："+totalTime+"ms");
        return result;
    }
}
